from classfile.attribute_info import AttributeInfo


class SourceFileAttribute(AttributeInfo):
    def __init__(self, constPool):
        super().__init__()
        self.constPool = constPool
        self.sourceFileIndex = 0

    def readInfo(self, clsReader):
        self.sourceFileIndex = int.from_bytes(clsReader.readU16(), "big")

    @property
    def fileName(self):
        return self.constPool.getUTF8(self.sourceFileIndex)
